package com.tgy.myplus.基础学习.Thread.Normal;


import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

//测试线程池
public class ThreadPool {
    public static void main(String[] args) {
        //创建服务，创建线程池

        //newFixedThreadPool参数为线程池大小
        ExecutorService executorService = Executors.newFixedThreadPool(10);
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());
        executorService.execute(new MyThread());

        //关闭连接
        executorService.shutdown();
    }
}

class MyThread implements Runnable{

    @Override
    public void run() {
        for (int i = 0; i < 3; i++) {
            System.out.println(Thread.currentThread().getName()+"----"+i);
        }
    }
}
